package com.chen.jwtbase.security.service;

import com.chen.jwtbase.security.entity.JwtUser;
import com.chen.jwtbase.system.entity.User;
import com.chen.jwtbase.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * @ClassName UserDetailsServiceImpl
 * @Description
 * @Author Mr-CHEN
 * @Date 2019/9/29 0029 10:34
 * @Version V1.0
 **/

@Service
public class UserDetailsServiceImpl implements UserDetailsService {

    @Autowired
    private UserService userService;

    @Override
    public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException {
        User user = userService.findUserByUserName(name);
        return new JwtUser(user);
    }
}